function HandleDirectory(gui, operator, now, options) {
  this._gui = gui;
  this._operator = operator;
  this._now = now;
  this._options = options;

  this._dirId = (options && options.d) ? options.d : 0;
  
  if (options) {
    this._createElements();
  }
};

HandleDirectory.prototype._createElements = function() {
  var tr, td;
  tr = this._gui.content.insertRow(-1);
  td = tr.insertCell(-1);
  td.style.width = '1000px';
  td.style.height = '465px';
  td.style.textAlign = 'center';
  td.style.verticalAlign = 'middle';
  td.appendChild(DOMUtils.getLoadingImage());
  
  this._loadData();
};

HandleDirectory.prototype._loadData = function() {
  this._files = null;
  this._retrieveFiles();
};

HandleDirectory.prototype._verifyData = function() {
  if (this._files) {
    this._updateElements();
  }
};

HandleDirectory.prototype._retrieveFiles = function() {
  var _self = this;
  new RequestUtils()._read('file', null, 'd.parentDirId=\'' + this._dirId + '\' AND d.customerTrackId=\'' + this._operator.trackId + '\'', null, null, 'd.name', null, function(result, params) { _self._files = result.data;
                                                                                                                                                                                                  _self._verifyData.call(_self);
                                                                                                                                                                                                }, null);
};

HandleDirectory.prototype._updateElements = function() {
  var _self = this;
  DOMUtils.removeChildElements(this._gui.content);
  
  var files = NPFileUtils.sortFile(this._files);
  for (var i = 0, il = files.length; i < il; i++) {
    var tmp = files[i];
    
    if (this._gui.content.rows.length == 0)  {
      td = this._gui.content.insertRow(-1).insertCell(-1);
    } else if (this._gui.content.rows[this._gui.content.rows.length - 1].cells.length < 5) {
      td = this._gui.content.rows[this._gui.content.rows.length - 1].insertCell(-1);
    } else {
      td = this._gui.content.insertRow(-1).insertCell(-1);
    }
    td.style.width = (files.length > 15) ? '202px' : '205px';
    td.style.textAlign = 'left';
    td.style.verticalAlign = 'top';
    new ModuleViewFileManage(document, td, 202, 165, this._operator, this._now, { item: tmp, selected: parent.document._goods, callbackFunc: parent.document._call[0].func, others: MiscUtils.remove(MiscUtils.clone(files), tmp, 'trackId'), index: i, length: files.length } );
  }
};

